
import Vue from 'vue'
import MsgFormat from './MsgFormat'
let _this = new Vue()
let ws = null



function connect() {
  // ws = new WebSocket("ws://39.96.57.148:8080/test")
  ws = new WebSocket("ws://localhost:5003/test")
  _this.$notify.info({
    title: '消息',
    message: '正在连接服务器...',
  })

  ws.onopen = () => {
    _this.$notify({
      title: '成功',
      message: '服务器连接成功!',
      type: 'success'
    })

  }
  ws.onerror = () => {
    _this.$notify({
      title: '警告',
      message: '服务器连接失败!',
      type: 'warning'
    });
  }


  return ws
}

export default {
  connect
}
